#pragma once
#include "HashTable_bucket.h"

template<class K>
class myunordered_set
{
	struct SetKeyOfT
	{
		const K& operator()(const K& key)
		{
			return key;
		}
	};
public:
	typedef typename Hash_bucket::HashTable<K, const K, SetKeyOfT>::Iterator iterator;
	typedef typename Hash_bucket::HashTable<K, const K, SetKeyOfT>::Const_Iterator const_iterator;

	iterator begin()
	{
		return _ht.Begin();
	}

	iterator end()
	{
		return _ht.End();
	}

	const_iterator begin() const
	{
		return _ht.Begin();
	}

	const_iterator end() const
	{
		return _ht.End();
	}

	pair<iterator, bool> insert(const K& key)
	{
		return _ht.Insert(key);
	}

	iterator find(const K& key)
	{
		return _ht.Find(key);
	}

	bool erase(const K& key)
	{
		return _ht.Erase(key);
	}
private:
	Hash_bucket::HashTable<K, const K, SetKeyOfT> _ht;
};

void Testunordered_set1()
{
	myunordered_set<int> s;
	s.insert(31);
	s.insert(11);
	s.insert(5);
	s.insert(15);
	s.insert(25);

	myunordered_set<int>::iterator it = s.begin();
	while (it != s.end())
	{
		//*it = 1;
		cout << *it << " ";
		++it;
	}
	cout << endl;

	for (auto e : s)
	{
		cout << e << " ";
	}
	cout << endl;
}
